package com.cn.enumeration.gpt;

/**
 * 枚举中的抽象方法
 */
public class Demo3 {
    public static void main(String[] args) {
        double result = Operation.PLUS.apply(3, 4);
        System.out.println("Result of PLUS operation: " + result);
    }

}

enum Operation {
    //这里面就是实现了抽象方法apply
    PLUS {
        public double apply(double x, double y) {
            return x + y;
        }
    },
    MINUS {
        public double apply(double x, double y) {
            return x - y;
        }
    };

    public abstract double apply(double x, double y);
}